from selenium import webdriver
from time import sleep
import unittest

from selenium.webdriver.common.by import By

from day0409.Page.Page1 import Page1
from day0409.Page.Page2 import Page2
from one.day0409.Page.Page3 import Page3
from day0409.Tools.Tools import Tools
from ddt import ddt,data,unpack
path= r'/one/day0409\Date\login.xlsx'
sheetname='Sheet1'
dy=Tools(path,sheetname)

@ddt

class TestCase(unittest.TestCase):

    def setUp(self) -> None:
        self.driver=webdriver.Edge()

    def tearDown(self) -> None:
        sleep(5)
        self.driver.quit()

    @data(*dy.getdata())
    @unpack
    def test_01_jiuxian(self,username,password,exp,tj):
        po=Page1(self.driver)
        po.jiuxian_luoji_01(username,password)
        sleep(2)

        if tj=='T1':

            po.qd()
            sleep(2)
            dy1=self.driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span').text
            print(dy1)
            self.assertEqual(exp,dy1)

        else:
            dy1=self.driver.find_element(By.XPATH,'//*[@id="validcaptcha"]/div[3]').text
            self.assertEqual(exp,dy1)

    @unittest.skip
    def test_02_jiuxian(self):
        po=Page2(self.driver)
        po.jiuxian_luoji_02()

    @unittest.skip
    def test_03_jiuxian(self):
        po=Page3(self.driver)
        po.jiuxian_luoji_01()
        po.jiuxian()
        po.dingdan()




if __name__ == '__main__':
    unittest.main()